package com.et114.components.mail;

import com.et114.components.junit.BaseTestCase;
import com.et114.components.mail.DefaultMailService;

import org.springframework.mail.SimpleMailMessage;

import java.util.Map;
import java.util.HashMap;

/**
 * @author guanhw
 */
public class TestMail extends BaseTestCase {
    private DefaultMailService  dms = null ;
    
    public void testSender() throws Exception {
			dms = ( DefaultMailService )this.getBean( "mailBean" ) ;
			SimpleMailMessage smm = new SimpleMailMessage () ;
			smm.setFrom( "hwguan@126.com" ) ; 
			smm.setTo( new String[]{ "apache.org@163.com" , "hwguan@126.com" } ) ;
			smm.setText( "您中奖了 5000万" ) ;
			smm.setSubject( "您中奖了 5000万" ) ;
			
			Map model = new HashMap();
			model.put( "test"  , "hello world ! ") ;
			//MailAttachment ma = new MailAttachment () ;
			//ma.addMailAttachment( "中文" , "d:/bak/中文.ftl" ) ; 
			dms.send( smm , "mailftl.ftl" , model  ) ;
			//dms.send( smm.getFrom() , smm.getTo()[ 0 ]  , smm.getSubject() , smm.getText() ) ;
			logger.info( "!!!" ) ;
    }
}
